cmake_minimum_required(VERSION 3.16)

if(CMAKE_HOST_LINUX)
    link_directories(
        third_party/linux/wxWidgets/lib
    )
    include_directories(
        third_party/linux/wxWidgets/include/wx-3.2
        third_party/linux/wxWidgets/lib/wx/include/gtk3-unicode-3.2/
    )

    link_libraries(
        wx_baseu_net-3.2
        wx_baseu_xml-3.2
        wx_baseu-3.2
        wx_gtk3u_adv-3.2
        wx_gtk3u_aui-3.2
        wx_gtk3u_core-3.2
        wx_gtk3u_gl-3.2
        wx_gtk3u_html-3.2
        wx_gtk3u_propgrid-3.2
        wx_gtk3u_qa-3.2
        wx_gtk3u_ribbon-3.2
        wx_gtk3u_richtext-3.2
        wx_gtk3u_stc-3.2
        wx_gtk3u_xrc-3.2
    )
endif(CMAKE_HOST_LINUX)

# set(WX_CONFIG_EXEC "wx-config")
# ../third_party/linux/wxWidgets/lib/wx/config/gtk3-unicode-3.2 --libs

option(WX_CONFIG_EXEC "用于提供配置 wxWidgets 的生成工具" "wx-config")

execute_process(COMMAND ${WX_CONFIG_EXEC} --cflags
    OUTPUT_VARIABLE WX_CONFIG_CFLAGS_VAR
    OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${WX_CONFIG_EXEC} --libs
    OUTPUT_VARIABLE WX_CONFIG_LIBS_VAR
    OUTPUT_STRIP_TRAILING_WHITESPACE)

# 基于空格分割为参数列表
separate_arguments(WX_CONFIG_CFLAGS UNIX_COMMAND ${WX_CONFIG_CFLAGS_VAR})
separate_arguments(WX_CONFIG_LIBS   UNIX_COMMAND ${WX_CONFIG_LIBS_VAR})

# spark_debug_message("WX_CONFIG_CFLAGS:")
# spark_debug_message("   ${WX_CONFIG_CFLAGS_VAR}")
# spark_debug_message("WX_CONFIG_LIBS:  ")
# spark_debug_message("   ${WX_CONFIG_LIBS_VAR}")

# 应用生成的内容
add_compile_options(
    ${WX_CONFIG_CFLAGS}
    ${WX_CONFIG_LIBS})

# 手动指定 wx-config 生成的配置
# 
# add_compile_options(
#     -pthread -lwx_gtk3u_xrc-3.2 -lwx_gtk3u_html-3.2 -lwx_gtk3u_qa-3.2 -lwx_gtk3u_core-3.2 -lwx_baseu_xml-3.2 -lwx_baseu_net-3.2 -lwx_baseu-3.2
#     -I/usr/lib/wx/include/gtk3-unicode-3.2 -I/usr/include/wx-3.2 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread
# )


# 构建 wxWidgets
# 
# git clone https://gitee.com/guyunli/wxWidgets --depth=1 --branch=v3.2.2.1
# git submodule update --init --recursive
# 
# ./configure --enable-cxx11 --with-sdl --prefix=/usr
# make DESTDIR=out install -j16
# 
# 你需要安装 libgtk-3-dev libsdl2-dev 才编译通过
# 正式程序运行时则需要 gtk 支持
# 
